#ifndef TREENODE_H
#define TREENODE_H

#include <QtCore/QString>
#include <QtCore/QVector>
#include <QtCore/QHash>

class TreeNode {
public:
    static QString aa;
    
public:
    TreeNode(const QString& id, const QString& parentId, const QString& name, TreeNode* parent = nullptr, int row = 0)
        : m_currentId(id), m_parentId(parentId), m_currentName(name), m_checkstate(Qt::Unchecked), m_parent(parent), m_row(row) {}

    QString getId() const { return m_currentId; }
    QString getParentId() const { return m_parentId; }
    QString getName() const { return m_currentName; }
    int getCheckState() const { return m_checkstate; }
    int getRow() const { return m_row; }
    
    void setCheckState(int checkstate) { this->m_checkstate = checkstate; }
    void setRow(int row) { this->m_row = row; }
    void setParent(TreeNode* parent){ this->m_parent = parent; }
    
    void addChild(TreeNode* child) { m_children.append(child); }
    QVector<TreeNode*> getChildren() const { return m_children; }
    TreeNode* getParent() const { return m_parent;};
    
    bool hasChildren() const { return !m_children.isEmpty(); }
    
private:
    QString m_currentId;
    QString m_parentId;
    QString m_currentName;
    int m_checkstate{Qt::Unchecked};
    QVector<TreeNode*> m_children;
    TreeNode* m_parent{nullptr};
    int m_row{-1};            // 在父节点中的位置
};

#endif // TREENODE_H
